hysop.topology.cartesian_topology module

class hysop.topology.cartesian_topology.CartesianTopology(domain, discretization, mpi_params=None, cart_dim=None, cart_shape=None, is_periodic=None, cutdirs=None, mesh=None, cartesian_topology=None, cl_env=None, **kwds)[source]

Bases: CartesianTopologyView, Topology

CartesianTopology topologies defined on cartesian meshes which communicates accross processes through a MPI CartesianTopology communicator.

Initialize this object. If self._initialized was already set to True, raise a RuntimeError. Else, set self._initialized to True.

static __new__(cls, domain, discretization, mpi_params=None, cart_dim=None, cart_shape=None, is_periodic=None, cutdirs=None, mesh=None, cartesian_topology=None, cl_env=None, **kwds)[source]

Initializes or get an existing CartesianTopology topology.

Parameters:
  • domain (Box) – The box geometry on which the cartesian topology is defined.

  • discretization (CartesianDiscretization) – Description of the global space discretization of the box (resolution, ghosts, and boundary conditions).

  • mpi_params (MPIParams, optional) – MPI parameters (comm, task …). If not specified, comm = domain.task_comm, task = domain.curent_task()

  • backend (Backend or ~hysop.core.arrays.ArrayBackend, optional) – Backend or backend kind for this topology. By default a topology will use Backend.HOST.

  • cart_dim (int, optional) – MPI topology dimension.

  • cart_shape (list or array of int, optional) – MPI grid layout, should be sized as the domain dimension.

  • is_periodic (tuple, list or array of bool, optional) – MPI grid periodicity, overrides discretization boundary conditions.

  • cutdirs (list or array of bool, optional) – Set which directions may be distributed, cutdirs[dir] = True allow MPI to distribute data along dir.

  • mesh (CartesianMesh, optional) – A predifined mesh (it includes local and global grids.)

  • cartesian_topology (Cartcomm, optional) – A predefined mpi cartesian topology. Use this when you need the same communicator for two different meshes/space distribution of data.

  • kwds (dict) – Base class arguments. Includes allocator, cl_env and queue.

global_resolution

Resolution of the global mesh (as given in the discretization parameter).

Type:

np.ndarray of HYSOP_INTEGER

ghosts

CartesianDiscretization ghosts of local-to-process mesh (as given in the discretization parameter).

Type:

np.ndarray of HYSOP_INTEGER

mesh

Local mesh on the current mpi process.

Type:

CartesianMeshView:

cart_comm

MPI cartesian topology intracommunicator.

Type:

Cartcomm

cart_dim

MPI_Cart topology dimension. Dimension of the MPI cartesian communicator. This dimension may be smaller than the domain dimension, because some directions may not be distributed.

Type:

int

cart_size

MPI_Cart grid size. Size of the MPI cartesian communicator (total number of MPI processes).

Type:

int

cart_rank

MPI_Cart rank. Rank of the current process in the cartesian communicator. May be different than self.mpi_params.rank.

Type:

int

cart_coords

Coordinate of this process in the cartesian communicator grid. The returned tuple is of dimension self.dimension.

Type:

np.ndarray of np.int32

cart_shape

MPI_Cart grid shape. Shape of the MPI cartesian communicator.

Type:

np.ndarray of np.int32

cart_periods

MPI_Cart grid periodicity

Type:

np.ndarray of bool

cart_ranks

Return all ranks of this cartesian topology as a np.ndarray such that array[cart_coords] = rank.

Type:

np.ndarray of np.int32

cart_ranks_mapping

Return all ranks of the parent MPI communicator as a np.ndarray such that array[cart_coords] = parent rank.

Type:

np.ndarray of np.int32

cart_neighbour_ranks

Return the ranks of the neighbours nodes as obtained by MPI_Cart_shift. self.neighbours[0,i] (resp. [1,i]) is the previous (resp. next) neighbour in direction i.

Type:

np.ndarray

proc_coords

Coordinates of this process in the extended cartesian grid (ie. with non distributed directions included). The returned tuple is of dimension self.domain_dim.

Type:

tuple of int

proc_shape

Processus grid shape, same as cart_shape but extended with non distributed directions.

Type:

tuple of int

proc_ranks

Return all ranks of this cartesian topology as a np.ndarray such that array[proc_coords] = rank.

Type:

np.ndarray of np.int32

proc_ranks_mapping

Return all ranks of the parent MPI communicator as a np.ndarray such that array[proc_coords] = parent rank.

Type:

np.ndarray of np.int32

proc_neighbour_ranks

Return the ranks of the neighbours nodes as obtained by MPI_Cart_shift. self.neighbours[0,i] (resp. [1,i]) is the previous (resp. next) neighbour in axe i. If axe is not distributed, self.neighbours[:,i] returns [-1,-1].

Type:

np.ndarray

is_distributed

Directions which have been distributed, is_distributed[dir] = True means that data has been distributed along dir.

Type:

tuple of bool

is_periodic

MPI grid periodicity. is_periodic[dir] = True means that the MPI grid is periodic along dir. /!This is not equivalent to domain periodicity, as a periodic

direction might not be distributed in the MPI cartesian grid or might be forced to be periodic for other reasons through the is_periodic parameter override. Domain periodicity is self.domain.periodicity

Type:

tuple of bool

Notes
------
\* Almost all parameters above are optional.

Only one must be chosen among dim, cutdirs and shape. See MPI topologies and space discretisation in the Hysop User Guide for details.

\* When cartesian_topology is given, dim, shape and cutdirs parameters,

if set, are not used to build the mpi topology, but compared with cartesian_topology parameters. If they do not fit, error is raised.

\* Unless is_periodic is specified periodicity is extracted

from domain boundary conditions.

\* All attributes are read-only properties.
discretize(field)[source]

Discretize a continous field on this topology and return a DiscreteField.

topology_like(backend=None, grid_resolution=None, ghosts=None, lboundaries=None, rboundaries=None, mpi_params=None, cart_shape=None, **kwds)[source]

Return a topology like this object, possibly altered.

view(topology_state)[source]

Returns a view of this topology with the given state.

class hysop.topology.cartesian_topology.CartesianTopologyState(dim, task_id, axes=None, memory_order=None, is_read_only=False, **kwds)[source]

Bases: TopologyState

CartesianTopology topology state. This is a helper class to qualify CartesianDiscreteField states.

A CartesianTopologyState contains informations about the way the application should perceive the contained data (Arrays) in CartesianDiscreteFields.

Those informations include for the current physical transposition state of the topology and the local meshes and the memory_order.

Currently the state is shared accross all components of the CartesianDiscreteField. This is global state for all processes contained in the linked Cartesian topology.

Initialize a CartesianState to given parameters.

Parameters:
  • dim (int) – Dimensiong of the underlying domain.

  • axes (tuple of ints, optional) – Permutation of the CartesianTopology and the meshes as tuple of ints, in numpy notations.

  • memory_order (hysop.constants.MemoryOrdering, optional) – Either C or Fortran memory order.

  • read_only (is) – Whether this topology is read only or not.

  • kwds (dict) – Base class keyword arguments.

property axes

Return current permutation as a tuple of int.

copy(axes=None, memory_order=None, is_read_only=None)[source]

Return a copy of self, some properties may be alterted in kwds.

property dim

Return the dimension of the underlying topology domain.

long_description()[source]

Return a long description of this CartesianTopologyState.

match(other, invert=False)[source]

Check if this topology state does match the other one.

property memory_order

Return current memory_order as a tuple (one memory_order per axis).

short_description()[source]

Return a short description of this CartesianTopologyState.

property task_id

Return the task identifier of the underlying topology domain.

transposed(vec)[source]

Compute permutation of input vector according to current transposition state.

property tstate

Return the TranspositionState corresponding to current permutation axes.

class hysop.topology.cartesian_topology.CartesianTopologyView(topology_state, topology=None, **kwds)[source]

Bases: TopologyView

CartesianTopology topology view. Basically a CartesianTopology topology with field transposition state taken into account.

Create and initialize a cartesian topology view.

Parameters:
  • topology_state (CartesianTopologyState) – State that charaterizes the given view.

  • topology (CartesianTopology) – Original cartesian topology on which the view is.

  • kwds (dict) – Base class keyword arguments.

static __new__(cls, topology_state, topology=None, **kwds)[source]

Create and initialize a cartesian topology view.

Parameters:
  • topology_state (CartesianTopologyState) – State that charaterizes the given view.

  • topology (CartesianTopology) – Original cartesian topology on which the view is.

  • kwds (dict) – Base class keyword arguments.

__str__()[source]

Same as self.long_description().

can_communicate_with(target)[source]

True if current topo is complient with target.

Complient means : - all processes in current are in target - both topologies belong to the same mpi task

property cart_comm

MPI cartesian topology intracommunicator.

property cart_coords

Current process MPI cartesian topology coordinates.

property cart_dim

MPI cartesian topology dimension.

property cart_neighbour_ranks

Return the ranks of the neighbours nodes as obtained by MPI_Cart_shift. self.neighbours[0,i] (resp. [1,i]) is the previous (resp. next) neighbour in axe i.

property cart_periods

MPI cartesian topology shape.

property cart_rank

Current process MPI cartesian topology rank.

property cart_ranks

Return all MPI cartesian topology ranks as np.ndarray.

property cart_ranks_mapping

Return all parent communicator topology ranks as np.ndarray.

property cart_shape

MPI cartesian topology shape.

property cart_size

MPI cartesian topology size.

property comm

Return the communicator of this topology.

default_state()[source]

Return the default topology state of this topology.

property distributed_axes

Return distributed axes ids as a np.ndarray of integers.

property ghosts

Returns ghosts of the discretization.

property global_resolution

Returns global resolution of the discretization (logical grid size).

property grid_resolution

Returns grid resolution of the discretization (effective grid size).

is_consistent_with(target)[source]

True if target and current object are equal and have the same parent. Equal means same mesh, same shape and same domain.

property is_distributed

Returns Directions which have been distributed, is_distributed[dir] = True means that data has been distributed along dir.

property is_periodic

MPI communicator grid periodicity. is_periodic[dir] = True means that the MPI grid is periodic along dir. /!This is not equivalent to domain periodicity, as a periodic

direction might not be distributed in the MPI cartesian grid or might be forced to be periodic for other reasons through the is_periodic parameter override.

long_description()[source]

Returns a long description of the current TopologyView. Long version of short_description().

property periodic_axes

Return cartesian communicator periodic axes ids as a np.ndarray of integers.

property proc_coords

Current process cartesian topology extended coordinates (ie. undistributed axes included).

property proc_neighbour_ranks

Return the ranks of the neighbours nodes as obtained by MPI_Cart_shift. self.neighbours[0,i] (resp. [1,i]) is the previous (resp. next) neighbour in axe i. If axe is not distributed, self.neighbours[:,i] returns [-1,-1].

property proc_ranks

Return all MPI cartesian topology ranks as np.ndarray undistributed axes included.

property proc_ranks_mapping

Return all parent communicator topology ranks as np.ndarray, undistributed axes included.

property proc_shape

MPI cartesian topology extended shape (ie. undistributed axes included).

short_description()[source]

Returns a short description of the current TopologyView. Short version of long_description().